<template>
        <view>
        <!-- 1.1 搜索框 开始 -->
        <view class="search-wrap">
        <u-search
            bg-color="#e7e7e7"
            placeholder="输入商品名"
            :show-action="false"
            @input="handleInput"
        ></u-search>
        </view>
        <!-- 1.1 搜索框 结束 -->
    </view>
</template>

<script>
// 延时器
let tiemId;
export default {
    data(){
        return {
            inp:'',
        }
    },
    methods: {
        async handleInput(inp){
            // 清空延时器
            if(tiemId){
                clearTimeout(tiemId)
            };

            // 定时器
            tiemId= setTimeout( async ()=>{
                // 请求 获取相应的
                const res = await this.$u.get("/goods/search", {
                    query:inp,
                    cid:'',
                    pagenum:1,
                    pagesize:10
                })
                console.log(res);
            },2000)
        }
    }
}
</script>

<style lang="scss">
.search-wrap {
    padding: 15rpx;
}
</style>